import java.io.*;
import java.lang.*;
import java.awt.Desktop;



public class openhtml
{
	public static Desktop desktop;

	public openhtml(String str)
	{
		//File file = new File("autorepair.html");
		try{
		FileWriter fstream = new FileWriter("autorepair.html");
			BufferedWriter out = new BufferedWriter(fstream);

			out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
			out.newLine();
			out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
			out.newLine();
			out.write("<head>");
			out.newLine();
			out.write("<title>My Google AJAX Search API Application</title>");
			out.newLine();
			out.write("    <script src=\"http://www.google.com/jsapi?\" type=\"text/javascript\"></script>");
			out.newLine();
			out.write("<script language=\"Javascript\" type=\"text/javascript\">");
			out.newLine();
			out.write("//<![CDATA[");
			out.newLine();
			out.write("google.load(\"search\", \"1\");");
			out.newLine();
			out.write("function gotResults(sc, searcher){");
			out.newLine();
			out.write("	var resultcontent = '';");
			out.newLine();
			out.write("	var resultdiv = document.getElementById('searchresults');");
			out.newLine();
			out.write("for (i=0; i<searcher.results.length; i++){");
			out.newLine();
			out.write("var result = searcher.results[i];");
			out.newLine();
			out.write("resultcontent += '<p>'+result.title+'<br />'+result.streetAddress+'</p>';}");
			out.newLine();
			out.write("resultdiv.innerHTML = resultcontent;}");
			out.newLine();
			out.write("function OnLoad() {");
			out.newLine();
			out.write("var searchControl = new google.search.SearchControl();");
			out.newLine();
			out.write("var localSearch = new google.search.LocalSearch();");
			out.newLine();
			out.write("var options = new google.search.SearcherOptions();");
			out.newLine();
			out.write("options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);");
			out.newLine();
			out.write("searchControl.addSearcher(localSearch, options);");
			out.newLine();
			out.write("localSearch.setCenterPoint(\""+str+"\");");
			out.newLine();
			out.write("searchControl.draw(document.getElementById(\"searchcontrol\"));");
			out.newLine();
			out.write("searchControl.setSearchCompleteCallback(this, gotResults);");
			out.newLine();
			out.write("searchControl.execute(\"auto repair\");}");
			out.newLine();
			out.write("google.setOnLoadCallback(OnLoad);");
			out.newLine();
			out.write("//]]>");
			out.newLine();
			out.write("</script>");
			out.newLine();
			out.write("<style>");
			out.newLine();
			out.write("#googleversion");
			out.newLine();
			out.write("{");
			out.newLine();
			out.write("margin-right: 50px;");
			out.newLine();
			out.write("}");
			out.newLine();
			out.write("</style>");
			out.newLine();
			out.write("</head>");
			out.newLine();
			out.write("<body>");
			out.newLine();
			out.write("<div id=\"googleversion\" class=\"localexample\">");
			out.newLine();
			out.write("<strong>Auto-generated by Google</strong>");
			out.newLine();
			out.write("<div id=\"searchcontrol\" style=\"\">Loading...</div>");
			out.newLine();
			out.write("	</div>");
			out.newLine();
			out.write("</body>");
			out.newLine();
			out.write("</html>");
			out.newLine();






			out.close();
		File file = new File("autorepair.html");
		desktop = Desktop.getDesktop();

		desktop.open(file);
		}
		catch(Exception e)
		{
			System.err.print(e);
		}
	}
	public static void main(String []args)
	{
		new openhtml("Pittsburgh, PA");
	}
}